package com.example.musicserver.mapper;

import com.example.musicserver.model.MusicInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MusicInfoMapper {
    @Select("select * from music")
    List<MusicInfo> getAllList();

    @Select("select * from music where title like concat('%',#{title},'%')")
    List<MusicInfo> getListByTitle(@Param("title") String title);

    @Insert("insert into music(title,singer,url,userid) values(#{title},#{singer},#{url},#{userid})")
    Integer addMusic(@Param("title") String title,@Param("singer") String singer,@Param("url") String url,@Param("userid") Integer userid);

    @Select("select * from music where title=#{title}")
    MusicInfo queryMusicByTitle(@Param("title") String title);

    @Delete("delete from music where id=#{id}")
    Integer deleteMusicByMId(@Param("id") Integer id);

    @Select("select * from music where id=#{id}")
    MusicInfo findMusicByMId(Integer id);
}
